import 'package:equatable/equatable.dart';
import 'package:backend.core/core/domain/entities/api/google_play/api_google_play_transaction_revocation_source.dart';

const kApiGooglePlayTransactionUserRevocationSourceValue = 'user';
const kApiGooglePlayTransactionDeveloperRevocationSourceValue = 'developer';
const kApiGooglePlayTransactionGoogleRevocationSourceValue = 'google';

class ApiGooglePlayTransactionRevocationSourceDto extends Equatable {
  const ApiGooglePlayTransactionRevocationSourceDto._internal({
    required this.sourceString,
  });

  final String sourceString;

  @override
  List<Object?> get props {
    return [
      sourceString,
    ];
  }

  factory ApiGooglePlayTransactionRevocationSourceDto.fromEntity(
      ApiGooglePlayTransactionRevocationSource source) {
    late final String sourceString;

    if (source == ApiGooglePlayTransactionRevocationSource.user) {
      sourceString = kApiGooglePlayTransactionUserRevocationSourceValue;
    } else if (source == ApiGooglePlayTransactionRevocationSource.developer) {
      sourceString = kApiGooglePlayTransactionDeveloperRevocationSourceValue;
    } else if (source == ApiGooglePlayTransactionRevocationSource.google) {
      sourceString = kApiGooglePlayTransactionGoogleRevocationSourceValue;
    }

    return ApiGooglePlayTransactionRevocationSourceDto._internal(
      sourceString: sourceString,
    );
  }

  @override
  String toString() {
    return sourceString;
  }
}
